<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org/">
<head>
    <meta charset="UTF-8">
    <title>报表</title>
    <link rel="stylesheet" href="../static/layui/css/layui.css" th:href="@{/layui/css/layui.css}">
</head>
<body>
<div>
    <form class="layui-form" action="" style="margin:4% 20%;">
        <div class="layui-form-item">
            <label class="layui-form-label">日期:</label>
            <div class="layui-input-block">
                <input type="text" name="odate" lay-verify="odate" placeholder="" autocomplete="off"
                       class="layui-input"
                       style="display: inline-block;width:70%">
                <button type="submit" class="layui-btn" lay-submit="" lay-filter="lookup">查找</button>
            </div>
        </div>
    </form>
    <table class="layui-hide" id="report" lay-filter="report"></table>

    <script type="text/html" id="barDemo">
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
    </script>
</div>
<script src="../static/layui/layui.js" th:src="@{/layui/layui.js}"></script>
<script>
    layui.use(['form', 'jquery', 'table'], function(){
        var form = layui.form,
            layer = layui.layer,
            $ = layui.jquery,
            table = layui.table;

        table.render({
            elem: '#report'
            ,url:'/aaaaaaaaa'
            ,toolbar: '#report' //开启头部工具栏，并为其绑定左侧模板
            ,defaultToolbar: ['filter', 'print', 'exports']
            ,title: '用户数据表'
            ,cols: [
                [
                {type: 'checkbox', fixed: 'left'}
                ,{field:'oid', title:'ID', width:80, fixed: 'left', unresize: true, sort: true}
                ,{field:'uid', title:'名字', width:120,
                templet:'<div>{{d.uid.uname}}</div>'}
                ,{field:'uid', title:'身份证号码', width:120,
                    templet:'<div>{{d.uid.uidcar}}</div>'}
                ,{field:'uid', title:'地址', width:120,
                    templet:'<div>{{d.uid.uaddress}}</div>'}
                ,{field:'uid', title:'电话号码', width:120,
                    templet:'<div>{{d.uid.pid.pnum}}</div>'}
                ,{field:'uid', title:'预存缴费', width:120,
                    templet:'<div>{{d.uid.pid.pstorage}}</div>'}
                ,{field:'uid', title:'月租', width:120,
                    templet:'<div>{{d.uid.pid.prent}}</div>'}
                ,{field:'lid', title:'操作员编号', width:120,
                    templet:'<div>{{d.lid.lname}}</div>'}
                ,{field:'tid', title:'业务类型', width:120,
                    templet:'<div>{{d.tid.tname}}</div>'}
                ,{field:'omoney', title:'缴费金额', width:120}
                ,{field:'odate', title:'时间', width:120}
                ,{fixed: 'right', title:'操作', toolbar: '#barDemo', width:150}
            ]
            ]
            ,page: true
        });
        //点击查找按钮
        form.on('submit(lookup)', function (data) {

        })
        //监听行工具事件
        table.on('tool(report)', function(obj){
            var data = obj.data;
            //console.log(obj)
            if(obj.event === 'del'){
                layer.confirm('真的删除行么', function(index){
                    obj.del();
                    layer.close(index);
                });
            } else if(obj.event === 'edit'){
                layer.prompt({
                    formType: 2
                    ,value: data.email
                }, function(value, index){
                    obj.update({
                        email: value
                    });
                    layer.close(index);
                });
            }
        });
    });
</script>
</body>
</html>